// Don't hack SPFA!
#include<bits/stdc++.h>
using namespace std;
int _25;
int n,m,l,vmax;
int p[1000005];
int d[1000005],v[1000005],a[1000005];
struct node{
	int v,nx;
}e[1000005];
int head[1000005],tot=1;
pair<int,int>nd[1000005];
pair<int,int>nw[1000005];
const double eps = 1e-7;
void addedge(int u,int v){
	e[++tot].v=v;e[tot].nx=head[u];head[u]=tot;
}
double ABS(double x){
	return (x>0?x:-x);
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&_25);
	while(_25--){
		scanf("%d%d%d%d",&n,&m,&l,&vmax);
		for(int i=1;i<=n;i=i+1){
			scanf("%d%d%d",&d[i],&v[i],&a[i]);
			nd[i]=make_pair(1,0);
		}
		for(int i=1;i<=m;i=i+1){
			scanf("%d",&p[i]);
		}
		p[m+1]=l+25;
		for(int i=1;i<=n;i=i+1){
			if(a[i]==0 and v[i]>vmax){
				nd[i]=make_pair(lower_bound(p+1,p+m+2,d[i])-p,m);
			}
			else if(v[i]>vmax and a[i]<0){
				double dis=((double)vmax*vmax-(double)v[i]*v[i])/(2*a[i]);
				int k=dis;
				if(ABS(dis-k)<=eps){
					--k;
				}
				if(k+d[i]>l){
					nd[i]=make_pair(lower_bound(p+1,p+m+2,d[i])-p,m);
				}
				else{
					int lst=lower_bound(p+1,p+m+2,k+d[i])-p;
					if(p[lst]>k+d[i]){
						--lst;
					}
					nd[i]=make_pair(lower_bound(p+1,p+m+2,d[i])-p,lst);
				}
			}
			else if(a[i]>0 and v[i]>vmax){
				nd[i]=make_pair(lower_bound(p+1,p+m+2,d[i])-p,m);
			}
			else if(a[i]>0){
				double dis=((double)vmax*vmax-(double)v[i]*v[i])/(2*a[i]);
				int k=(int)dis+1;
				if(ABS(dis-(k-1))<=eps){
					++k;
				}
				if(k+d[i]<=l){
					nd[i]=make_pair(lower_bound(p+1,p+m+2,k+d[i])-p,m);
				}
			}
		}
		int sum=0;
		//~ memset(head,0,sizeof(head));
		//~ tot=0;
		for(int i=1;i<=n;i=i+1){
			//~ cout<<nd[i].first<<" "<<nd[i].second<<endl;
			if(nd[i].second>=nd[i].first){
				nw[++sum]=nd[i];
				swap(nw[sum].first,nw[sum].second);
				//~ addedge(j,i-1,-1 );
			}
		}
		if(sum==0){
			printf("0 %d\n",m);
			continue;
		}
		nw[sum+1]=make_pair(m+25,m+32);
		sort(nw+1,nw+sum+2);
		for(int i=1;i<=sum;i=i+1){
			swap(nw[i].first,nw[i].second);
		}
		int ans=0,cur=0;
		for(int i=1;i<=sum;i=i+1){
			if(nw[i].first>cur){
				cur=nw[i].second;
				++ans;
			}
		}
		printf("%d %d\n",sum,m-ans);
	}
	return 0;
}
//                                                                                                                                                                                                                                                                                                                                                                       
